package com.xzz.insitu;

import com.xzz.listnode.ListNode;

/**
 * @author: hhz
 * @create: 2021-12-29 11:54
 * 83. 删除排序链表中的重复元素
 **/
public class DeleteDuplicates {
    public ListNode deleteDuplicates(ListNode head) {
        if(head ==null){
            return head;
        }
        ListNode slow = head;
        ListNode fast = head;
        while(fast != null){
            if(fast.val!=slow.val){
                slow.next = fast;
                slow = slow.next;
            }
            fast = fast.next;
        }
        slow.next = null;
        return head;
    }
}
